import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


public class ServletConfig01 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");

        //获取ServletConfig对象
        javax.servlet.ServletConfig config=this.getServletConfig();

        //获取初始化参数
        String num=config.getInitParameter("Number");
        String name=config.getInitParameter("Name");
        PrintWriter out=resp.getWriter();
        out.print("<html>");
        out.print("<body>");
        out.print("<h2>"+"Number = "+num+"<h2>");
        out.write("<h2>"+"Name = "+name+"<h2>");
        out.print("</body>");
        out.print("</html>");
        out.flush();
        out.close();
    }
}
